<template>
  <div class="Root">
    <!-- 一条文章单元格 -->
    <van-cell>
      <!-- 标题区域的插槽 -->
      <template #title>
        <div class="title-box">
          <!-- 标题 -->
          <span>{{ artitem.title }}</span>
          <img
            class="thumb"
            v-lazy="artitem.cover.images[0]"
            v-if="artitem.cover.type === 1"
          />
        </div>
        <div class="thumb-box" v-if="artitem.cover.type > 1">
          <img
            class="thumb"
            v-for="(imgUrl, index) in artitem.cover.images"
            :key="index"
            v-lazy="imgUrl"
          />
        </div>
      </template>
      <!-- label 区域的插槽 -->
      <template #label>
        <div class="label-box">
          <div>
            <span>作者{{ artitem.aut_name }}</span>
            <span>评论{{ artitem.comm_count }}</span>
            <span>{{ formateTime(artitem.pubdate) }}</span>
          </div>
          <!-- 反馈按钮 -->
          <van-icon name="cross"   @click.stop="onCloseClick" v-if="isShow"/>
        </div>
      </template>
    </van-cell>
    <van-action-sheet v-model="show" :actions="actions" @select="onSelect"  get-container="body" :cancel-text="cancelText" @cancel="oncancel" @close="close" />
  </div>
</template>

<script>
import { timeAgo } from "@/utils/date.js"; 
import { firstActions, secondActions } from '@/api/reports'
export default {
  name: "",
  components: {},
  props: {
    artitem: Object,
    isShow:{
      type:Boolean,
      default:true
    }
  },
  data() {
    return {
      show: false,
      actions: firstActions,
      cancelText:'取消*'
    };
  },
  watch: {},
  computed: {},
  methods: {
    formateTime: timeAgo,
    onSelect(action) {
      if(action.name === '反馈垃圾内容'){
        this.actions = secondActions;
        this.cancelText = '返回'
      }else if(action.name ==='不感兴趣'){
      
        this.$emit('disLikeEV',this.artitem.art_id)

        this.show = false
      }else{
        this.$emit('reportEV',this.artitem.art_id,action.value);
        this.actions = firstActions;
        this.show = false
      }
      
    },
    oncancel(){
      if (this.cancelText === '返回') {
        this.actions = firstActions
        this.cancelText = '取消'
        this.show = true 
      }
    },
    close(){
       this.actions = firstActions
        this.cancelText = '取消' 
    },
    onCloseClick(){
      this.show = true
    }
  },
  created() {},
  mounted() {},
};
</script>
<style lang="less" scoped>
.title-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* label描述样式 */
.label-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 文章信息span */
.label-box span {
  margin: 0 3px;
  &:first-child {
    margin-left: 0;
  }
}
/* 图片的样式, 矩形黄金比例：0.618 */
.thumb {
  width: 113px;
  height: 70px;
  background-color: #f8f8f8;
  object-fit: cover;
}

/* 三图, 图片容器 */
.thumb-box {
  display: flex;
  justify-content: space-between;
}
</style>